<layout name='layout' />

<div class="admin-main">

	<blockquote class="layui-elem-quote">
		<button class="layui-btn layui-btn-small" onclick="openModel('<{:U('Subject/add')}>','添加主题','80%','80%');">
			<i class="fa fa-plus"></i> 添加主题
		</button>

		<button class="layui-btn layui-btn-small" onclick="window.location.reload();">
			<i class="fa fa-refresh"></i> 刷新
		</button>

		<button class="layui-btn layui-btn-small layui-btn-danger" id="delBtn">
			<i class="fa fa-close"></i> 删除
		</button>

	</blockquote>

	<fieldset class="layui-elem-field">
		<legend>数据列表</legend>
		<div class="layui-field-box">
			<form id="ajaxForm" method="post" action="<{:U('Subject/del')}>">
			<table class="site-table table-hover">
				<thead>
					<tr>
						<th><input type="checkbox" id="selected-all"></th>								
						<TH>名称</TH>
						<TH>类型</TH> 
						<TH>投票选项</TH>  
						<TH>截止日期</TH> 
						<TH>添加日期</TH>
						<TH>更新日期</TH>
						<TH>操作</TH>
					</tr>
				</thead>
				<tbody>
					<volist name="list" id="vo">
					<tr>
						<td><input type="checkbox" name="selectedids[]" value="<{$vo.id}>"></td>
						<td><{$vo.name}></td>
						<td><eq name="vo.type" value="radio">单选<else/>多选</eq></td>
						<td><{$vo.number}>条</td>
						<td><{$vo.endTime|date="Y-m-d",###}></td>	  
						<td><{$vo.createTime|date='Y-m-d H:i:s',###}></td>
						<td><{$vo.updateTime|date='Y-m-d H:i:s',###}></td>
						<td>
						<a href="javascript:void(0)" onclick="openModel('<{:U('Subject/edit' , array('id'=>$vo['id']))}>','编辑主题','80%','80%');" class="layui-btn layui-btn-mini">编辑</a>
						<a href="javascript:void(0);" data-id="<{$vo['id']}>" class="layui-btn layui-btn-mini clearBtn">清空票数</a>
						<a href="javascript:void(0);" onclick="openModel('<{:U('Question/index' , array('sid'=>$vo['id']))}>','投票选项','80%','80%');" class="layui-btn layui-btn-mini">投票选项</a>
						</td>
					</tr>	
					</volist>						
				</tbody>
			</table>
			</form>
		</div>
	</fieldset>
	<div class="admin-table-page">
		<div id="page" class="page"><{$page}></div>
	</div>
</div>

<script type="text/javascript">
$(function(){
	$(".clearBtn").click(function(){
		id = $(this).attr("data-id");
		layer.msg('确定删除吗？', {
			time:0,
			btn: ['确定', '取消'],
			yes: function(index){
		    	layer.close(index);
		    	$.ajax({
					url: "<{:U('Subject/clear')}>&id="+id+"&temp="+new Date().getTime(),
					success: function (data){
						if(data==1){
							parent.layer.open({
								type:0, 
								icon:1,
								content:'操作成功'
							});
						}else{
							parent.layer.open({
								type:0, 
								icon:2,
								content:'操作失败'
							});
						}
					},
				});
			}
		});
	});
})
</script>